<?php
declare (strict_types=1);

use think\facade\Route;

/**
 * 试卷练习
 */
Route::group('admin/module/<module_id>/examination', function () {
    // 试卷练习配置
    Route::rule('config', 'config', 'GET|POST');
    // 新建试卷
    Route::post('create', 'create');
    // 试卷选择面板
    Route::get('choose/options', 'getChooseOptions');
    // 获取试卷列表
    Route::get('choose/list', 'getChooseList');
    // 试卷操作
    Route::group('<examination_id>', function () {
        // 编辑试卷
        Route::put('edit', 'edit');
        // 编辑试卷某个字段
        Route::put('edit/<field>', 'editField')->pattern(['field' => '[a-zA-Z_]+']);
    })->pattern(['examination_id' => '\d+']);
    // 移除试卷
    Route::delete('<id>/delete', 'delete')->pattern(['id' => '\d+']); // 删除
    // 批量移除
    Route::delete('deletes/<ids>', 'deletes')->pattern(['ids' => '[\d,]+']);// 批量删除
})->prefix('\app\exam\service\admin\ModuleExamination@')
    ->middleware('adminRoute')
    ->pattern(['module_id' => '\d+']);

/** 公开考试订单 */
Route::group('admin/examination/order', function () {
    // 订单列表
    Route::get('$', 'orderList');
    // 订单导出
    Route::post('export', 'export');
})->prefix('\app\exam\service\admin\Order@')
    ->middleware('adminRoute')
    ->append(['product_key' => 'examination']);